<?php
namespace app\admin\model;

class Log extends AdminModel
{
	protected $name = 'system_log';

	protected $autoWriteTimestamp = true;
	protected $createTime = 'createtime';
	protected $updateTime = false;
	protected $schema = [
		'id' => 'int',
		'admin_id' => 'int',//操作人
		'controller' => 'string',//操作的控制器
		'action' => 'string',//操作的方法
		'method' => 'string',//请求类型
		'query' => 'string',//请求参数
		'createtime' => 'int',//操作时间
		'ip' => 'string',//操作ip
		'name' => 'string'
	];
	protected $append=[
		'path_info'
	];
	/**
	 * 新增、更新需要操作的字段
	 */
	protected $submitField = [
	];

	public function adminUser(){
		return $this->belongsTo(User::class,'admin_id')->bind(['nickname','account']);
	}

	public function getPathInfoAttr($value,$data){
		$pathinfo = '/'.join('/',['admin',$data['controller'],$data['action']]);
		return $pathinfo;
	}

}

